# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, val=0, next=None):
#         self.val = val
#         self.next = next
class Solution:
    def swapPairs(self, head: ListNode) -> ListNode:
        # 此处一定是or否二无法通过编译
        if not head or not head.next:
            return head
        first = head
        second = head.next
        # 指向second的下一个节点,如果下一个节点依旧有head.next也就是两个节点,递归
        first.next = self.swapPairs(second.next)
        second.next = first
        return second